<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <title>商家详情</title>
    <link rel="stylesheet" href="${ctx}/static/plug/frozenui-1.3.0/css/frozen.css" media="all">
    <link rel="stylesheet" href="${ctx}/static/css/user/register.css" media="all">
    <style type="text/css">
        .div-form-detail {
            height: 25px;
            line-height: 25px;
        }

        .div-form-detail input {
            height: 25px;
            line-height: 25px;
        }

        .demo-block {
            position: relative;
        }

        .demo-block .ui-header,
        .demo-block .ui-footer {
            position: absolute;
        }

        .demo-block > .ui-list, .demo-block > .ui-form, .demo-block > .ui-tooltips {
            margin-bottom: 20px;
        }
    </style>
</head>
<body ontouchstart="">

<header class="ui-header ui-header-stable ui-border-b">
    <i class="ui-icon-return" onclick="history.back()"></i>
    <h1></h1>
    <button class="ui-btn" id="btnBackHome">回商家管理首页</button>
</header>
<footer class="ui-footer ui-footer-stable  ui-btn-group ui-border-t">
    <button class="ui-btn-lg" id="btnEditShop">编辑资料
    </button>
    <button class="ui-btn-lg" id="btnFrozenShop">冻结商家
    </button>
    <button class="ui-btn-lg ui-btn-primary" id="btnDelShop">删除商家
    </button>
</footer>
<section class="ui-container">
    <div class="ui-whitespace">
        <p class="ui-txt-info" id="shopName" style="margin-top: 3%">${parkingShop.name}</p>
        <input type="hidden" id="status" value="${parkingShop.status}"/>
    </div>

    <div class="ui-form ui-border-t" style="margin-top: 3%">
        <p class="ui-txt-info" style="padding-left: 15px">商家登陆账号</p>
        <div class="ui-form-item ui-form-item-show div-form-detail">
            <label>账号:</label>
            <input type="text" id="entNo" value="${parkingShop.authInfo.entNo}"/>
        </div>
        <div class="ui-form-item ui-form-item-show div-form-detail">
            <label>密码:</label>
            <input type="text" id="password" value="${parkingShop.authInfo.password}"/>
        </div>
    </div>

    <div class="ui-form ui-border-t" style="margin-top: 3%">
        <p class="ui-txt-info" style="padding-left: 15px">商户详细资料</p>
        <div class="ui-form-item ui-form-item-show div-form-detail">
            <label>商家名称:</label>
            <input type="text" id="name" value="${parkingShop.name}"/>
        </div>
        <div class="ui-form-item ui-form-item-show div-form-detail">
            <label>户主名称:</label>
            <input type="text" id="ownerName" value="${parkingShop.ownerName}"/>
        </div>
        <div class="ui-form-item ui-form-item-show div-form-detail">
            <label>电话:</label>
            <input type="text" id="phone" value="${parkingShop.phone}"/>
        </div>
        <div class="ui-form-item ui-form-item-show div-form-detail">
            <label>商铺位置:</label>
            <input type="text" id="location" value="${parkingShop.location}"/>
        </div>
        <div class="ui-form-item ui-form-item-show div-form-detail">
            <label>商家类别:</label>
            <input type="text" id="type" value="${parkingShop.typeName}"/>
        </div>
    </div>
</section>
<section id="dialog">
    <div class="demo-block">
        <div class="ui-dialog div-ui-dialog">
            <div class="ui-dialog-cnt" style="width:80%">
                <header class="ui-dialog-hd ui-border-b">
                    <h1 class="ui-icon-info"></h1>
                </header>
                <div class="ui-dialog-bd">
                    <div id="confirmMessage"></div>
                </div>
                <div class="ui-dialog-ft">
                    <button type="button" id="btnConfirm" data-role="button">确定</button>
                    <button type="button" id="btnCancel" data-role="button">取消</button>
                </div>
            </div>
        </div>
    </div>
</section>

</body>
<script src="${ctx}/static/plug/frozenui-1.3.0/lib/zepto.min.js"></script>
<script src="${ctx}/static/plug/frozenui-1.3.0/js/frozen.js"></script>
<script>

    var paramObj = {
        "shopListParams": "${shopListParams}",
        "deleteShopParams": "${deleteShopParams}",
        "editShopParams": "${editShopParams}",
        "frozenShopParams": "${frozenShopParams}"
    };


    $(function () {
        var status=$("#status").val();
        //商家状态，1:正常, 0:冻结，-1删除
        if(status == 0){
            $("#btnFrozenShop").html("解除冻结");
        }else if(status == 1 ){
            $("#btnFrozenShop").html("冻结商家");
        }

        $("#btnBackHome").click(function(){
            var hrefUrl = "${action}?params=" + paramObj.shopListParams;
            window.location.href = hrefUrl;
        });

        $("#btnDelShop").click(function () {
            $("#confirmMessage").html("删除后商家账号将不复存在,确定删除吗?");
            $(".div-ui-dialog").addClass("show");
            $("#btnConfirm").bind("click", function () {
                deleteShop();
            });
        });
        $("#btnEditShop").click(function () {
            var hrefUrl = "${action}?params=" + paramObj.editShopParams;
            window.location.href = hrefUrl;
        });
        $("#btnFrozenShop").click(function () {
            //商家状态，1:正常, 0:冻结，-1删除
            if( status==1 ){
                $("#confirmMessage").html("冻结商家账户之后,商家账户将无法发放停车券,但商家账户会保留,确定冻结吗?");
            }else{
                $("#confirmMessage").html("确认将此商家解除冻结吗？");
            }
            $(".div-ui-dialog").addClass("show");
            $("#btnConfirm").bind("click", function () {
                frozenShop();
            });
        });
        $("#btnCancel").click(function () {
            $(".div-ui-dialog").removeClass("show");
        });

        var canFrozen = true;
        function frozenShop() {
            $(".div-ui-dialog").removeClass("show");
            if (canFrozen) {
                var paraObj = {
                    "params": paramObj.frozenShopParams,
                    "status" : $("#status").val()
                };
                canFrozen = false;
                $.post("${action}", paraObj, function (obj) {
                    if (obj.result) {
                        showTips("info", "冻结成功");
                        var hrefUrl = "${action}?params=" + paramObj.shopListParams;
                        window.location.href = hrefUrl;
                    } else {
                        $("#showMsgP").html(obj.msg);
                    }
                    canFrozen = true;
                });
            }
        }

        var canDelete = true;
        function deleteShop() {
            $(".div-ui-dialog").removeClass("show");
            if (canDelete) {
                var paraObj = {
                    "params": paramObj.deleteShopParams
                };
                canDelete = false;
                $.post("${action}", paraObj, function (obj) {
                    if (obj.result) {
                        showTips("info", "删除成功");
                        var hrefUrl = "${action}?params=" + paramObj.shopListParams;
                        window.location.href = hrefUrl;
                    } else {
                        $("#showMsgP").html(obj.msg);
                    }
                    canDelete = true;
                });
            }
        }

    });


</script>
</html>